if(!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.envDef.envDtls.genInfo.GenInfo")) {
    jsx3.require("com.gix.gui.Block")

    /**
     * EnterpriseAssets
     */
    jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.envDef.envDtls.genInfo.GenInfo",
            com.gix.gui.Block,
            null,
            function (genInfo) {

                genInfo.prototype.lastMsg = null;

                /**
                 * instance initializer
                 * @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
                 * @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
                 * @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
                 */
                genInfo.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
                    //call constructor for super class (the super expects the name of the object and the function that it is an instance of)
                    this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
                };

                genInfo.prototype.subscribeAll = function() {
                    tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.envDef.EventID.ENVIRONMENT_ROW_SELECTED, this, this.onEnvironmentSelect);
                }

                genInfo.prototype.unsubscribeAll = function() {
                    tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.envDef.EventID.ENVIRONMENT_ROW_SELECTED, this);
                }

                //called whenever one of the environments in the evironments list is selected
                genInfo.prototype.onEnvironmentSelect = function(objEvent, useCached) {
                    if(this.handler && this.handler.isInEditMode()) {
                        return;
                    }
                    if(!objEvent) {
                        if(useCached && this.lastMsg) {
                            objEvent = this.lastMsg;
                        }
                    }
                    else {
                        this.lastMsg = objEvent;
                    }
                    var objCDFDocument = tibco.admin.Main.getServer().getCache().getDocument(objEvent.cacheID);
                    if(!objCDFDocument) {
                        this.populateDetails(null);
                        return;
                    }
                    var id = objEvent ? objEvent.environmentID : null;
                    var objRec = objCDFDocument.selectSingleNode("//record[@jsxid='" + id + "']");
                    this.populateDetails(objRec);
                    this.entityId = (objRec)?objRec.getAttribute("entityId"):"";

                };

                genInfo.prototype.populateDetails = function(objRec) {
                    if(objRec) {
                        this.getDescendantOfName("lblNameValue_27B").setText(objRec.getAttribute("name"), true);
                        this.getDescendantOfName("textDescriptionValue_27B").setText(objRec.getAttribute("description"), true);
                        this.getDescendantOfName("lblCreatedByValue_27B").setText(objRec.getAttribute("createdBy"), true);
                        this.getDescendantOfName("lblCreatedOnValue_27B").setText(tibco.admin.util.MatrixHelper.formatDate(objRec.getAttribute("creationDate")), true);
                        this.getDescendantOfName("lblContactValue_27B").setText(objRec.getAttribute("contact"), true);
                        if(this.mode == "VIEW") {
                            this.getDescendantOfName("btnEdit_27B").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                            this.getDescendantOfName("btnEdit_27B").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                        }
                    }
                    else {
                        this.getDescendantOfName("lblNameValue_27B").setText("", true);
                        this.getDescendantOfName("textDescriptionValue_27B").setText("", true);
                        this.getDescendantOfName("lblCreatedByValue_27B").setText("", true);
                        this.getDescendantOfName("lblCreatedOnValue_27B").setText("", true);
                        this.getDescendantOfName("lblContactValue_27B").setText("", true);
                        this.getDescendantOfName("btnEdit_27B").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                        if(this.mode == "EDIT") {
                            this.onCancelEnvironment();
                        }
                    }

                }


                // called when the edit button clicked
                genInfo.prototype.onEditEnvironment = function() {
                    this.handler.beginEditMode();
                    this.setGenInfoEditMode(true);
                    this.mode = "EDIT";
                };

                // called when the cancel button clicked
                genInfo.prototype.onCancelEnvironment = function() {
                    this.handler.endEditMode();
                    this.setGenInfoEditMode(false);
                    this.mode = "VIEW";
                };

                // called when the save button clicked
                genInfo.prototype.onSaveEnvironment = function() {
                    this.calleditEnvironment();
                };

                // Set the edit mode or view mode for the component UI.
                genInfo.prototype.setGenInfoEditMode = function(bEditMode, bSaveChange) {
                    this.switchElement("lblNameValue_27B", "textboxName_27B", bEditMode, bSaveChange);
                    this.switchElement("textDescriptionValue_27B", "textboxDescription_27B", bEditMode, bSaveChange);
                    this.switchElement("lblContactValue_27B", "textboxContact_27B", bEditMode, bSaveChange);
                    this.getDescendantOfName("btnEdit_27B").setDisplay(bEditMode ? jsx3.gui.Block.DISPLAYNONE : jsx3.gui.Block.DISPLAYBLOCK, true);
                    this.getDescendantOfName("btnCancel_27B").setDisplay(bEditMode ? jsx3.gui.Block.DISPLAYBLOCK : jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("btnSave_27B").setDisplay(bEditMode ? jsx3.gui.Block.DISPLAYBLOCK : jsx3.gui.Block.DISPLAYNONE, true);
                };

                // Switch GUI label to textbox, and textbox to label
                genInfo.prototype.switchElement = function(blkName, txtboxName, bEditMode, bSaveChange) {
                    var textboxObject = this.getDescendantOfName(txtboxName);
                    var blkObject = this.getDescendantOfName(blkName);
                    if(bSaveChange)
                    {
                        if(bEditMode)
                            textboxObject.setValue(blkObject.getText()).repaint();
                        else
                            blkObject.setText(textboxObject.getValue(), true);
                    }
                    textboxObject.setValue(blkObject.getText()).repaint();
                    textboxObject.setDisplay(bEditMode ? jsx3.gui.Block.DISPLAYBLOCK : jsx3.gui.Block.DISPLAYNONE, true);
                    blkObject.setDisplay(bEditMode ? jsx3.gui.Block.DISPLAYNONE : jsx3.gui.Block.DISPLAYBLOCK, true);
                };

                //call this method to begin the service call (eg.service.calleditEnvironment();)
                genInfo.prototype.calleditEnvironment = function() {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/envDef/envDtls/genInfo/rules/editEnvironmentRules.xml",
                            "editEnvironment",
                            "Edit environment");
                    objService.entityId = this.entityId
                    //subscribe and call it.
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.oneditEnvironmentSuccess);
                    objService.subscribe(jsx3.net.Service.ON_ERROR, this, this.oneditEnvironmentError);
                    objService.subscribe(jsx3.net.Service.ON_INVALID, this, this.oneditEnvironmentInvalid);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getEnvironmentEndpointURL());
                    objService.doCall();

                };

                // publish environment save successful event.
                genInfo.prototype.oneditEnvironmentSuccess = function(objEvent) {
                    this.handler.endEditMode();
                    this.setGenInfoEditMode(false, true);
                    this.mode = "VIEW";
                    var msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.envDef.EventID.ENVIRONMENT_EDIT_SUCCESSEFUL;
                    msg.entityId = this.entityId
                    tibco.admin.PubSub.publish(msg);

                };

                genInfo.prototype.oneditEnvironmentError = function(objEvent) {
                };

                genInfo.prototype.oneditEnvironmentInvalid = function(objEvent) {
                };

            });

}
